<template>
	<view class="container">
		<view class="goods-details" v-if="activityDetail.goods_content">
			<rich-text :nodes="activityDetail.goods_content" :data-nodes="activityDetail.goods_content"></rich-text>
		</view>
		<view class="footer fixfooter" :class="{ 'bottom-safe-area': isIphoneX }">
			<view class="submit" @click="makeApoint()">立即预约</view>
		</view>
		<!-- <sign :show="showSign" @close="closePop" :price="activityDetail.price" :memberPrice="goodsDetail.member_price" :backUrl="backUrl" :goodsid="id" v-if="showSign" ref="signDetail"></sign> -->
	</view>
</template>

<script>
	import htmlParser from '@/common/js/html-parser';
	import sign from '../../components/sign/sign.vue'
	export default {
		components: {
			sign
		},
		data() {
			return {
				isIphoneX: false, //判断手机是否是iphoneX以上
				showSign: false,
				id: '',
				activityDetail: {},
				backUrl: '/otherpages/food/privateRefDetail'
			}
		},
		onLoad(data) {
			this.isIphoneX = this.$util.uniappIsIPhoneX()
			this.id = data.id;
		    this.getDetail();
		},
		onShow() {
			// if(this.$refs.signDetail) this.$refs.signDetail.getDefaultAddress()
		},
		methods: {
			closePop() {
				this.showSign = false;
			},
			makeApoint() {
				if(!uni.getStorageSync('token')) {
					this.$util.showToast({title: '请先登录'})
					return
				}
				// this.showSign = true
				let params = {
					price: this.activityDetail.price,
					memberPrice: this.activityDetail.member_price,
					goodsid: this.id
				}
				this.$util.redirectTo('/otherpages/serviceSign/serviceSign?params=' + JSON.stringify(params))

			},
			getDetail() {
				this.$api.sendRequest({
			      url: "/api/food/goodsinfo",
			      data: {
			        goods_id: this.id,
			      },
			      success: res => {
			        if(res.code == 0) {
			         this.activityDetail = res.data;
					 // 商品详情
					  if (this.activityDetail.goods_content) this.activityDetail.goods_content = htmlParser(this.activityDetail.goods_content);

					 uni.setNavigationBarTitle({
						title: this.activityDetail.goods_name
					 })
			        }else {
						this.$util.showToast(res.message);
					}
			      }
			    })
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>
